package com.canaan.business.common.enums.quality;

import com.canaan.common.utils.StringUtils;

/**
 * 物料质检任务状态枚举
 */
public enum QualityTaskStatusEnum {

    /*
    待检验
     */
    WAIT("WAIT", "待检验"),
    /*
    检验中
     */
    INSPECTION("INSPECTION", "检验中"),
    /*
    已完成
     */
    COMPLETED("COMPLETED", "已完成");

    private final String code;
    private final String message;

    QualityTaskStatusEnum(String code, String info)
    {
        this.code = code;
        this.message = info;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static String getMessageByCode(String code){
        for(QualityTaskStatusEnum inspectionStatusEnum: QualityTaskStatusEnum.values()){
            if(StringUtils.isEmpty(code)){
                return null;
            }
            if(code.equals(inspectionStatusEnum.code)){
                return inspectionStatusEnum.message;
            }
        }
        return null;
    }

    public static String getCodeByMessage(String message){
        for(QualityTaskStatusEnum inspectionStatusEnum: QualityTaskStatusEnum.values()){
            if(StringUtils.isEmpty(message)){
                return null;
            }
            if(message.equals(inspectionStatusEnum.message)){
                return inspectionStatusEnum.code;
            }
        }
        return null;
    }
}
